<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div>aaaa</div>
  <script>
  
    setTimeout(() => {
      console.log("0")
    }, 0)
    
    new Promise((resolve,reject)=>{
      console.log("1")
      resolve()
    })
    .then(()=>{       
      console.log("2")
      new Promise((resolve,reject)=>{
        console.log("3")
        resolve()
      }).then(()=>{      
        console.log("4")
      }).then(()=>{ // 执行4       
        console.log("5")
      })
      // return undefined
    })
    .then(()=>{  
      console.log("6")
    })

    new Promise((resolve,reject)=>{
      console.log("7")
      resolve()
    }).then(()=>{         
      console.log("8")
    })

    /* 
    promise内部:  []
    宏: []
    微:  []  
    输出: 
    */

    new Promise((resolve) => {
      setTimeout(() => {
        resolve(1) // 将内部保存的回调函数放入微队列中
      }, 1000);
    }).then(value => {

    })

    // promise对象内部有一个数组来保存所有指定的回调函数  等放入队列的回调
    new Promise((resolve) => {
      resolve(1)
    }).then(value => { // 回调1

    }).then(value => { // 回调2

    })
    // 回调1在微队列中
    // 回调2在promise内部的数组中


  </script>
</body>
</html>